From 6c48136bc490892003968bdc5a65ae366dde24d4 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Thu, 10 Nov 2005 12:06:50 +0100 Subject: [PATCH] Add some minor defensive coding/error handling in xc_vmx_build.c like C/S 7687 Signed-off-by: Haifeng Xue Signed-off-by: Xin Li --- tools/libxc/xc_vmx_build.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c index c81346558f..f22d7ece4c 100644 --- a/tools/libxc/xc_vmx_build.c +++ b/tools/libxc/xc_vmx_build.c @@ -565,8 +565,10 @@ static int setup_guest(int xc_handle, return 0; error_out: - free(mmu); - free(page_array); + if ( mmu != NULL ) + free(mmu); + if ( page_array != NULL ) + free(page_array); return -1; } @@ -627,7 +629,7 @@ int xc_vmx_build(int xc_handle, if ( mlock(&st_ctxt, sizeof(st_ctxt) ) ) { - PERROR("xc_vmx_build: ctxt mlock failed"); + PERROR("%s: ctxt mlock failed", __func__); return 1; } @@ -661,7 +663,8 @@ int xc_vmx_build(int xc_handle, goto error_out; } - free(image); + if ( image != NULL ) + free(image); ctxt->flags = VGCF_VMX_GUEST; /* FPU is set up to default initial state. */ @@ -707,7 +710,8 @@ int xc_vmx_build(int xc_handle, return rc; error_out: - free(image); + if ( image != NULL ) + free(image); return -1; } -- 2.30.2